import Taro, { Component } from '@tarojs/taro'
import { AtCountdown } from 'taro-ui'
import classNames from 'classnames'
import PropsType from 'prop-types'
import { View, Image, Text } from '@tarojs/components'
import '../styles/itemtime.scss'

class DItemTime extends Component {

    onTimeUp(t) {
        this.props.onTimeUp && this.props.onTimeUp(...arguments)
    }

    render() {
        const {
            className,
            title = '剩余:',
            isShowDay = false,
            isShowHour = false,
            day = 0,
            hours = 0,
            minutes = 30,
            seconds = 0
        } = this.props
		
		console.log("time",day,hours,minutes,seconds)
        return (
            <View className={classNames("b_itemtimebox", className)}>
                {
                    title && <View className='b_itemtimebox__title'>{title}</View>
                }
                <AtCountdown
                    isShowDay={isShowDay}
                    isShowHour={isShowHour}
                    day={day}
                    hours={hours}
                    minutes={minutes}
                    seconds={seconds}
                    onTimeUp={this.onTimeUp.bind(this)}
                ></AtCountdown>
            </View>
        )
    }


}

DItemTime.PropsType = {
    className: PropsType.oneOfType[PropsType.string, PropsType.object],
    title: PropsType.string,
    isShowDay: PropsType.bool,
    isShowHour: PropsType.bool,
    day: PropsType.number,
    hours: PropsType.number,
    minutes: PropsType.number,
    seconds: PropsType.number,
    onTimeUp: PropsType.func
}


export default DItemTime